package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhClubDemandRelation;
import com.laowang.project.system.service.MyCyhClubDemandRelationService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 俱乐部要求关联Controller
 * 
 * @author laowang
 * @date 2024-07-26
 */
@Api(tags = "俱乐部要求关联接口")
@RestController
@RequestMapping("/clubDemandRelation")
public class MyCyhClubDemandRelationController extends BaseController {
    @Autowired
    private MyCyhClubDemandRelationService myCyhClubDemandRelationService;


    @ApiOperation(value = "小程序端 查询俱乐部要求",notes = "")
    @GetMapping("/web/{clubId}")
    public AjaxResult list(@PathVariable("clubId") Integer clubId) {
        MyCyhClubDemandRelation myCyhClubDemandRelation =  new MyCyhClubDemandRelation();
        myCyhClubDemandRelation.setClubId(clubId);
        List<MyCyhClubDemandRelation> list = myCyhClubDemandRelationService.selectMyCyhClubDemandRelationList(myCyhClubDemandRelation);
        return AjaxResult.success("操作成功",list);
    }


    /**
     * 查询俱乐部要求关联列表
     */
    @ApiOperation(value = "查询俱乐部要求关联列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:clubDemandRelation:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCyhClubDemandRelation myCyhClubDemandRelation) {
        startPage();
        List<MyCyhClubDemandRelation> list = myCyhClubDemandRelationService.selectMyCyhClubDemandRelationList(myCyhClubDemandRelation);
        return getDataTable(list);
    }
    
    /**
     * 导出俱乐部要求关联列表
     */
    @ApiOperation(value = "导出俱乐部要求关联列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:clubDemandRelation:export')")
    @Log(title = "俱乐部要求关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhClubDemandRelation myCyhClubDemandRelation) {
        List<MyCyhClubDemandRelation> list = myCyhClubDemandRelationService.selectMyCyhClubDemandRelationList(myCyhClubDemandRelation);
        ExcelUtil<MyCyhClubDemandRelation> util = new ExcelUtil<MyCyhClubDemandRelation>(MyCyhClubDemandRelation.class);
        return util.exportExcel(list, "clubDemandRelation");
    }

    /**
     * 获取俱乐部要求关联详细信息
     */
    @ApiOperation(value = "获取俱乐部要求关联详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:clubDemandRelation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhClubDemandRelationService.selectMyCyhClubDemandRelationById(id));
    }

    /**
     * 新增俱乐部要求关联
     */
    @ApiOperation(value = "新增俱乐部要求关联",notes = "")
    @PreAuthorize("@ss.hasPermi('my:clubDemandRelation:add')")
    @Log(title = "俱乐部要求关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhClubDemandRelation myCyhClubDemandRelation) {
        return toAjax(myCyhClubDemandRelationService.insertMyCyhClubDemandRelation(myCyhClubDemandRelation));
    }

    /**
     * 修改俱乐部要求关联
     */
    @ApiOperation(value = "修改俱乐部要求关联",notes = "")
    @PreAuthorize("@ss.hasPermi('my:clubDemandRelation:edit')")
    @Log(title = "俱乐部要求关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody MyCyhClubDemandRelation myCyhClubDemandRelation) {
        return toAjax(myCyhClubDemandRelationService.updateMyCyhClubDemandRelation(myCyhClubDemandRelation));
    }

    /**
     * 删除俱乐部要求关联
     */
    @ApiOperation(value = "删除俱乐部要求关联",notes = "")
    @PreAuthorize("@ss.hasPermi('my:clubDemandRelation:remove')")
    @Log(title = "俱乐部要求关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhClubDemandRelationService.deleteMyCyhClubDemandRelationByIds(ids));
    }
}
